//
//  ViewController.m
//  jcctest
//
//  Created by 蒋晨成 on 16/5/31.
//  Copyright © 2016年 蒋晨成. All rights reserved.
//

#import "ViewController.h"

#import "RCLabel.h"
#import "HtmlString.h"
@interface ViewController ()<RCLabelDelegate>

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    NSString *contentStr = @"#NBASummer# @adsd 克拉克森（提前送上）儿童节，快乐！ http://t.cn/R5U9T3H .";
    NSString *str = [HtmlString transformString:contentStr];
    RCLabel *textLabel = [[RCLabel alloc]initWithFrame:CGRectMake(10,160,300,84)];
    textLabel.delegate =self;
   
    [textLabel setFont:[UIFont systemFontOfSize:15]];
    RCLabelComponentsStructure *componentsDS = [RCLabel extractTextStyle:str];
    textLabel.componentsAndPlainText = componentsDS;
    CGSize optimalSize = [textLabel optimumSize:YES];
    textLabel.frame=CGRectMake(10,180,300, optimalSize.height+5);
    textLabel.lineBreakMode = NSLineBreakByCharWrapping;
    textLabel.backgroundColor = [UIColor clearColor];
    textLabel.textColor = [UIColor colorWithRed:33.0/255 green:33.0/255 blue:33.0/255 alpha:1];
    [self.view addSubview:textLabel];
    
    
}

-(void)RCLabel:(id)RCLabel didSelectLinkWithURL:(NSString *)url
{
    NSLog(@"%@",url);
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
